import { defineStore } from 'pinia';
import { Notification } from '@arco-design/web-vue';
import type { NotificationReturn } from '@arco-design/web-vue/es/notification/interface';
import type { RouteRecordNormalized } from 'vue-router';
import { useUserStore, useAppStore, useRouterStore } from '@/store';
// import HOMEPAGE from '@/router/routes/client-modules/homepage';

// import ORDER from '@/router/routes/client-modules/order';
// import BUYMG from '@/router/routes/client-modules/buy-mg';
// import CONTRACT from '@/router/routes/client-modules/contract';
// import INVENTORY from '@/router/routes/client-modules/inventory';
// import EQUIPMENT from '@/router/routes/client-modules/equipment';

import router from '@/router';

const useMenusStore = defineStore('menus', {
  state: () => {
    return {
      // 存放当前菜单路由,默认为首页
      currMenus: [],
    };
  },

  actions: {
    // 点击头部导航获取当前的侧边栏菜单
    setCurrMenus(item: string) {
      const data = JSON.parse(sessionStorage.getItem('SideBarRouters'));
      switch (item) {
        case '/homepage': // 首页
          this.currMenus = []; // 每次跳转先清空
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus)); // 将当前路由信息保存到sessionStorage
          break;
        case '/order': // 订单管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        case '/buyMg': // 采购管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        case '/contract': // 合同管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        case '/inventory': // 库存管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        case '/equipment': // 设备管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        case '/FactoryModeling': // 设备管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        case '/production': // 生产管理
          this.currMenus = [];
          this.currMenus = data.filter((i) => i.path === item);
          sessionStorage.setItem('currMenus', JSON.stringify(this.currMenus));
          break;
        default:
          break;
      }
    },
  },
});

export default useMenusStore;
